﻿using System;
using System.Data;
using BLL;
using DAL;
using Ext.Net;
using Roles;

namespace ERP.Modules
{
    public partial class UserPermisstion : System.Web.UI.UserControl
    {
        #region[Define]
        private static bool _flag;
        private DataTable _dtGetUserPermisstionFillter;
        private DataTable _dtGetUserPermisstion;
        private DataTable _dtGetUserPermisstionEdit;
        private DataTable _dtGetModulesMain;
        private DataTable _dtGetModulesPrrent;
        private DataTable _dtGetModulesPrrentDetail;
        private DataTable _dtGetGroupUser;
        private DataTable _dtGetGroupUserDetail;
        private readonly BllUserPermisstion _clsUserPermisstion = new BllUserPermisstion();
        private readonly BllModules _clsModules = new BllModules();
        private readonly BllModulesParent _clsModulesParrent =new BllModulesParent();
        private readonly BllGroupUser _clsGroupUser = new BllGroupUser();
        #endregion

        #region[Controler]
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                CheckPermisstion();
                GetUserPermisstion();
                GetModulesMainFillter();
                GetModulesParrentFillter();
                GetGroupUserFillter();
                btnEdit.Disable(true);
                btnDel.Disable(true);
                btnExport.Disable(true);
            }
        }
        //Store
        protected void StorePermisstionModules_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            GetModulesParrent();
        }
        protected void StoreUserPermisstion_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            SelectBoxModulesMainUserPermisstion.Text = string.Empty;
            SelectBoxModulesParrentUserPermisstion.Text = string.Empty;
            SelectBoxUserGorupUserPermisstion.Text = string.Empty;
            GetUserPermisstion();
            GetModulesMainFillter();
            GetModulesParrentFillter();
            GetGroupUserFillter();
        }
        protected void StoreGroupUserPermisstionModules_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            txtSearchGroupUserPermisstion.Text = string.Empty;
            GetGroupUser();
        }
        //Button
        protected void btnAddNew_Click(object sender, DirectEventArgs e)
        {
            _flag = true;
           ClearText();
           WindowsUserPermisstion.Show();
           txtModulesMain.Focus(false, 100);
        }
        protected void btnEdit_Click(object sender, DirectEventArgs e)
        {
            var gridParam = e.ExtraParams["grUserPermisstion"];
            UpdateRow(gridParam);
        }
        protected void btnDel_Click(object sender, DirectEventArgs e)
        {
            var sm = grUserPermisstion.GetSelectionModel() as CheckboxSelectionModel;
            if (sm != null)
                foreach (var row in sm.SelectedRows)
                {
                    try
                    {
                        var obj = new EtUserPermisstion { Id = int.Parse(row.RecordID) };
                        BllUserPermisstion.Delete(obj);

                    }
                    catch (Exception ex)
                    {
                        HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
                    }
                }
            GetUserPermisstion();
        }
        protected void btnSavePopUp_Click(object sender, DirectEventArgs e)
        {
            Insert();
        }
        protected void btnCancelPopUp_Click(object sender, DirectEventArgs e)
        {
            WindowsUserPermisstion.Close();
        }
        protected void btnAddModules_Click(object sender, DirectEventArgs e)
        {
            SelectBoxPermisstionModulesCode.Text = string.Empty;
            GetModulesMain();
            grPermisstionModules.GetStore().RemoveAll();
            WindowUserPermisstionModules.Show();
        }
        protected void btnGroupUserPermiss_Click(object sender, DirectEventArgs e)
        {
            txtSearchGroupUserPermisstion.Text = string.Empty;
            GetGroupUser();
            WindowGroupUserPermisstionModules.Show();
        }
        //Search
        protected void Search_Event(object sender, DirectEventArgs e)
        {
            DataTable dtSearch = _clsUserPermisstion.GetUserPermisstion(txtSearch.Text, int.Parse(Session["USer_Detail_Id"].ToString()));
            if (dtSearch != null && dtSearch.Rows.Count > 0)
            {
                StoreUserPermisstion.DataSource = dtSearch;
                StoreUserPermisstion.DataBind();
            }
            else
            {
                grUserPermisstion.GetStore().RemoveAll();
            }
        }
        protected void txtSearchGroupUserPermisstion_Event(object sender, DirectEventArgs e)
        {
            DataTable dtSearch = _clsGroupUser.GetGroupUser(txtSearch.Text);
            if (dtSearch != null && dtSearch.Rows.Count > 0)
            {
                StoreGroupUserPermisstionModules.DataSource = dtSearch;
                StoreGroupUserPermisstionModules.DataBind();
            }
            else
            {
                grGroupUserPermisstionModules.GetStore().RemoveAll();
            }
        }
        //Select-box
        protected void SelectIndexPermisstionModules_Change(object sender, DirectEventArgs e)
        {
            hdIDModulesMain.Text = string.Empty;
            txtModulesMain.Text = string.Empty;
            GetModulesParrent();
            hdIDModulesMain.Text = SelectBoxPermisstionModulesCode.SelectedItem.Value;
            txtModulesMain.Text = SelectBoxPermisstionModulesCode.SelectedItem.Text;
        }
        protected void SelectIndexUserPermisstion_Change(object sender, DirectEventArgs e)
        {
            SelectBoxModulesParrentUserPermisstion.Text = string.Empty;
            SelectBoxUserGorupUserPermisstion.Text = string.Empty;
            GetUserPermisstion();
        }
        protected void SelectIndexModulesParrentUserPermisstion_Change(object sender, DirectEventArgs e)
        {
            SelectBoxModulesMainUserPermisstion.Text = string.Empty;
            SelectBoxUserGorupUserPermisstion.Text = string.Empty;
            GetUserPermisstion();
        }
        protected void SelectIndexGorupUserPermisstion_Change(object sender, DirectEventArgs e)
        {
            SelectBoxModulesMainUserPermisstion.Text = string.Empty;
            SelectBoxModulesParrentUserPermisstion.Text = string.Empty;
            GetUserPermisstion();
        }
        //Double-Click
        protected void UserPermisstionDblClick(object sender, DirectEventArgs e)
        {
            _flag = false;
            ClearText();
            int id = int.Parse(e.ExtraParams["ID"]);
            GetUserPermisstionEdit(id);
            WindowsUserPermisstion.Show();
        }
        //Click
        protected void PermisstionModules_Click(object sender, DirectEventArgs e)
        {
            var sm = grPermisstionModules.GetSelectionModel() as CellSelectionModel;
            if (sm != null)
            {
                var id = sm.SelectedCell.RecordID;
                GetModulesParrentEdit(int.Parse(id));
            }
            if (sm != null)
            {
                sm.Clear();
                sm.UpdateSelection();
            }
            WindowUserPermisstionModules.Close();
        }
        protected void GroupUserPermisstionModules_Click(object sender, DirectEventArgs e)
        {
            var sm = grGroupUserPermisstionModules.GetSelectionModel() as CellSelectionModel;
            if (sm != null)
            {
                var id = sm.SelectedCell.RecordID;
                GetGroupUserDetail(int.Parse(id));
            }
            if (sm != null)
            {
                sm.Clear();
                sm.UpdateSelection();
            }
            WindowGroupUserPermisstionModules.Close();
        }
        //Tiger-Click
        protected void RefreshTigerPermisstionModules_Click(object sender, DirectEventArgs e)
        {
            SelectBoxPermisstionModulesCode.Text = string.Empty;
            GetModulesMain();
            grPermisstionModules.GetStore().RemoveAll();
        }
        #endregion

        #region[Method]
        private void GetUserPermisstion()
        {
            if (SelectBoxModulesMainUserPermisstion.Text == string.Empty &&
                SelectBoxModulesParrentUserPermisstion.Text == string.Empty &&
                SelectBoxUserGorupUserPermisstion.Text == string.Empty)
            {
                _dtGetUserPermisstion = _clsUserPermisstion.GetUserPermisstionAll(txtSearch.Text);
                if (_dtGetUserPermisstion != null && _dtGetUserPermisstion.Rows.Count > 0)
                {
                    StoreUserPermisstion.DataSource = _dtGetUserPermisstion;
                    StoreUserPermisstion.DataBind();
                }
                else
                {
                    grUserPermisstion.GetStore().RemoveAll();
                }
            }
            else
            {
                _dtGetUserPermisstionFillter =
                    _clsUserPermisstion.GetUserPermisstionFillter(
                        SelectBoxModulesMainUserPermisstion.SelectedItem.Value,
                        SelectBoxModulesParrentUserPermisstion.SelectedItem.Value,
                        SelectBoxUserGorupUserPermisstion.SelectedItem.Value);
                if (_dtGetUserPermisstionFillter != null && _dtGetUserPermisstionFillter.Rows.Count > 0)
                {
                    StoreUserPermisstion.DataSource = _dtGetUserPermisstionFillter;
                    StoreUserPermisstion.DataBind();
                }
                else
                {
                    grUserPermisstion.GetStore().RemoveAll();
                }
            }
        }
        private void GetUserPermisstionEdit(int id)
        {
            _dtGetUserPermisstionEdit = _clsUserPermisstion.GetUserPermisstionEdit(id);
            if (_dtGetUserPermisstionEdit != null && _dtGetUserPermisstionEdit.Rows.Count > 0)
            {
                hdIDUserPermisstion.Text = _dtGetUserPermisstionEdit.Rows[0]["ID"].ToString();
                hdIDModulesMain.Text = _dtGetUserPermisstionEdit.Rows[0]["ModulesMain_ID"].ToString();
                hdIDModulesParrent.Text = _dtGetUserPermisstionEdit.Rows[0]["ModulesParent_ID"].ToString();
                hdIDGroup_User.Text = _dtGetUserPermisstionEdit.Rows[0]["Group_Id"].ToString();
                txtModulesMain.Text = _dtGetUserPermisstionEdit.Rows[0]["ModulesMainDescripttion"].ToString();
                txtModulesParrent.Text = _dtGetUserPermisstionEdit.Rows[0]["ModulesParentDescripttion"].ToString();
                txtGroupName.Text = _dtGetUserPermisstionEdit.Rows[0]["Group_Name"].ToString();
                txtDescription.Text = _dtGetUserPermisstionEdit.Rows[0]["Descripttion"].ToString();
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnView"])
                {
                    chkAddNew.Checked = true;
                }
                else
                {
                    chkAddNew.Checked = false;
                }
                //------------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnEdit"])
                {
                    chkEdit.Checked = true;
                }
                else
                {
                    chkEdit.Checked = false;
                }
                //-----------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnDelete"])
                {
                    chkDel.Checked = true;
                }
                else
                {
                    chkDel.Checked = false;
                }
                //-------------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnReview"])
                {
                    chkReview.Checked = true;
                }
                else
                {
                    chkReview.Checked = false;
                }
                //------------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnCancel"])
                {
                    chkCancel.Checked = true;
                }
                else
                {
                    chkCancel.Checked = false;
                }
                //--------------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnPrint"])
                {
                    chkPrint.Checked = true;
                }
                else
                {
                    chkPrint.Checked = false;
                }
                //-------------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsbtnView"])
                {
                    chkView.Checked = true;
                }
                else
                {
                    chkView.Checked = false;
                }
                //-------------
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsPageMain"])
                {
                    chkIsPageModuleMain.Checked = true;
                }
                else
                {
                    chkIsPageModuleMain.Checked = false;
                }
                if ((bool)_dtGetUserPermisstionEdit.Rows[0]["IsPageParrent"])
                {
                    chkIsPageModulesParrent.Checked = true;
                }
                else
                {
                    chkIsPageModulesParrent.Checked = false;
                }
            }
        }
        private void GetModulesMain()
        {
            _dtGetModulesMain = _clsModules.GetModulesMain(string.Empty);
            if (_dtGetModulesMain != null && _dtGetModulesMain.Rows.Count > 0)
            {
                StoreOrderPermisstionModules.DataSource = _dtGetModulesMain;
                StoreOrderPermisstionModules.DataBind();
            }
            else
            {
                SelectBoxPermisstionModulesCode.GetStore().RemoveAll();
            }
        }
        private void GetModulesParrent()
        {
            _dtGetModulesPrrent =
                _clsModulesParrent.GetModulesParrentMain(int.Parse(SelectBoxPermisstionModulesCode.SelectedItem.Value));
            if (_dtGetModulesPrrent != null && _dtGetModulesPrrent.Rows.Count > 0)
            {
                StorePermisstionModules.DataSource = _dtGetModulesPrrent;
                StorePermisstionModules.DataBind();
            }
            else
            {
                grPermisstionModules.GetStore().RemoveAll();
            }
        }
        private void GetModulesParrentEdit(int id)
        {
            _dtGetModulesPrrentDetail = _clsModulesParrent.GetModulesParentEdit(id);
            if (_dtGetModulesPrrentDetail != null && _dtGetModulesPrrentDetail.Rows.Count > 0)
            {
                hdIDModulesParrent.Text = _dtGetModulesPrrentDetail.Rows[0]["ModulesParent_ID"].ToString();
                txtModulesParrent.Text = _dtGetModulesPrrentDetail.Rows[0]["Descripttion"].ToString();
            }
        }
        private void GetGroupUser()
        {
            _dtGetGroupUser = _clsGroupUser.GetGroupUser(txtSearchGroupUserPermisstion.Text);
            if (_dtGetGroupUser != null && _dtGetGroupUser.Rows.Count > 0)
            {
                StoreGroupUserPermisstionModules.DataSource = _dtGetGroupUser;
                StoreGroupUserPermisstionModules.DataBind();
            }
            else
            {
                grGroupUserPermisstionModules.GetStore().RemoveAll();
            }
        }
        private void GetGroupUserDetail(int id)
        {
            _dtGetGroupUserDetail = _clsGroupUser.GetGroupUserEdit(id);
            if (_dtGetGroupUserDetail != null && _dtGetGroupUserDetail.Rows.Count > 0)
            {
                hdIDGroup_User.Text = _dtGetGroupUserDetail.Rows[0]["Group_Id"].ToString();
                txtGroupName.Text = _dtGetGroupUserDetail.Rows[0]["Group_Name"].ToString();
            }
        }
        private void GetModulesMainFillter()
        {
            DataTable _dtGetModulesMainFillter = _clsModules.GetModulesMain(string.Empty);
            if (_dtGetModulesMainFillter != null && _dtGetModulesMainFillter.Rows.Count > 0)
            {
                StoreModulesMainUserPermisstion.DataSource = _dtGetModulesMainFillter;
                StoreModulesMainUserPermisstion.DataBind();
            }
            else
            {
                SelectBoxModulesMainUserPermisstion.GetStore().RemoveAll();
            }
        }
        private void GetModulesParrentFillter()
        {
            DataTable _dtGetModulesParrentFillter = _clsModulesParrent.GetModulesParent(string.Empty);
            if (_dtGetModulesParrentFillter != null && _dtGetModulesParrentFillter.Rows.Count > 0)
            {
                StoreModulesParrentUserPermisstion.DataSource = _dtGetModulesParrentFillter;
                StoreModulesParrentUserPermisstion.DataBind();
            }
            else
            {
                SelectBoxModulesParrentUserPermisstion.GetStore().RemoveAll();
            }
        }
        private void GetGroupUserFillter()
        {
            DataTable _dtGetGroupUserFillter = _clsGroupUser.GetGroupUser(string.Empty);
            if (_dtGetGroupUserFillter != null && _dtGetGroupUserFillter.Rows.Count > 0)
            {
                StoreUserGorupUserPermisstion.DataSource = _dtGetGroupUserFillter;
                StoreUserGorupUserPermisstion.DataBind();
            }
            else
            {
                SelectBoxUserGorupUserPermisstion.GetStore().RemoveAll();
            }
        }
        private bool CheckInsert()
        {
            bool check = false;
            DataTable dtMaterialsCheck = _clsUserPermisstion.GetUserPermisstion(string.Empty, int.Parse(Session["USer_Detail_Id"].ToString()));
            if (dtMaterialsCheck != null && dtMaterialsCheck.Rows.Count > 0)
            {
                foreach (DataRow dr in dtMaterialsCheck.Rows)
                {
                    if (hdIDModulesParrent.Text == dr["ModulesParent_ID"].ToString() && hdIDGroup_User.Text == dr["Group_Id"].ToString())
                    {
                        check = true;
                    }
                }
            }
            return check;
        }
        private bool CheckInsertUpdate()
        {
            var check = false;
            var dtCheck = _clsUserPermisstion.GetUserPermisstion(string.Empty, int.Parse(Session["USer_Detail_Id"].ToString()));
            if (dtCheck != null && dtCheck.Rows.Count > 0)
            {
                foreach (DataRow dr in dtCheck.Rows)
                {
                    if (hdIDUserPermisstion.Text != dr["ID"].ToString())
                    {
                        if (hdIDModulesMain.Text == dr["ModulesParent_ID"].ToString() && hdIDGroup_User.Text == dr["Group_Id"].ToString())
                        {
                            check = true;
                            HTML.clsFormat.Alert_ERROR("Thông Báo",
                                "Tên nhóm người dùng này đã tồn tại.Vui lòng chọn tên nhóm người dùng khác !.Một nhóm người dùng không thể tồn tại trong cùng một Module.");
                        }
                    }
                }
            }
            return check;
        }
        private void Insert()
        {
            if (_flag)
            {
                InsertValue();
            }
            else
            {
                if (CheckPermisstionDobclick())
                {
                    HTML.clsFormat.Alert_ERROR("Thông Báo", "Bạn không được cấp quyền để sửa đổi !");
                }
                else
                {
                    UpdateValue();
                }
            }
        }
        private void InsertValue()
        {
            try
            {
                if (CheckInsert())
                {
                    HTML.clsFormat.Alert_ERROR("Thông Báo", "Tên nhóm người dùng này đã tồn tại.Vui lòng chọn tên nhóm người dùng khác !.Một nhóm người dùng không thể tồn tại trong cùng một Module.");
                }
                else
                {
                    var obj = new EtUserPermisstion
                    {
                        ModulesMainId = int.Parse(hdIDModulesMain.Text),
                        ModulesParentId = int.Parse(hdIDModulesParrent.Text),
                        GroupId = int.Parse(hdIDGroup_User.Text),
                        PermisstionNumber = 0,
                        IsbtnAddNew = chkAddNew.Checked,
                        IsbtnEdit = chkEdit.Checked,
                        IsbtnView = chkView.Checked,
                        IsbtnDelete = chkDel.Checked,
                        IsbtnReview = chkReview.Checked,
                        IsbtnCancel = chkCancel.Checked,
                        IsbtnPrint = chkPrint.Checked,
                        IsPageMain = chkIsPageModuleMain.Checked,
                        IsPageParrent = chkIsPageModulesParrent.Checked,
                        Descripttion = txtDescription.Text
                    };
                    BllUserPermisstion.Insert(obj);
                    HTML.clsFormat.Alert_INFO("Thông Báo", "Phân quyền thành công !");
                    GetUserPermisstion();
                    ClearText();
                }
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Lỗi", ex.Message);
            }
        }
        private void UpdateValue()
        {
            try
            {
                if (!CheckInsertUpdate())
                {
                    var obj = new EtUserPermisstion
                    {
                        Id = int.Parse(hdIDUserPermisstion.Text),
                        ModulesMainId = int.Parse(hdIDModulesMain.Text),
                        ModulesParentId = int.Parse(hdIDModulesParrent.Text),
                        GroupId = int.Parse(hdIDGroup_User.Text),
                        PermisstionNumber = 0,
                        IsbtnAddNew = chkAddNew.Checked,
                        IsbtnEdit = chkEdit.Checked,
                        IsbtnView = chkView.Checked,
                        IsbtnDelete = chkDel.Checked,
                        IsbtnReview = chkReview.Checked,
                        IsbtnCancel = chkCancel.Checked,
                        IsbtnPrint = chkPrint.Checked,
                        IsPageMain = chkIsPageModuleMain.Checked,
                        IsPageParrent = chkIsPageModulesParrent.Checked,
                        Descripttion = txtDescription.Text
                    };
                    BllUserPermisstion.Update(obj);
                    HTML.clsFormat.Alert_INFO("Thông Báo", "Cấp lại quyền thành công !");
                    WindowsUserPermisstion.Close();
                    GetUserPermisstion();
                }
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Lỗi", ex.Message);
            }
        }
        private void UpdateRow(string param)
        {
            try
            {
                var json = JSON.Deserialize<DataTable>(param);
                if (string.IsNullOrEmpty(param))
                {
                    return;
                }
                foreach (DataRow dr in json.Rows)
                {
                    var obj = new EtUserPermisstion
                    {
                        Id = int.Parse(dr["ID"].ToString()),
                        ModulesMainId = int.Parse(dr["ModulesMain_ID"].ToString()),
                        ModulesParentId = int.Parse(dr["ModulesParent_ID"].ToString()),
                        GroupId = int.Parse(dr["Group_Id"].ToString()),
                        IsbtnView = bool.Parse(dr["IsbtnView"].ToString()),
                        IsbtnAddNew = bool.Parse(dr["IsbtnAddNew"].ToString()),
                        IsbtnEdit = bool.Parse(dr["IsbtnEdit"].ToString()),
                        IsbtnDelete = bool.Parse(dr["IsbtnDelete"].ToString()),
                        IsbtnReview = bool.Parse(dr["IsbtnReview"].ToString()),
                        IsbtnCancel = bool.Parse(dr["IsbtnCancel"].ToString()),
                        IsbtnPrint = bool.Parse(dr["IsbtnPrint"].ToString()),
                        IsPageMain = bool.Parse(dr["IsPageMain"].ToString()),
                        IsPageParrent = bool.Parse(dr["IsPageParrent"].ToString()),
                        Descripttion = dr["Descripttion"].ToString()
                    };
                    BllUserPermisstion.Update(obj);
                }
                HTML.clsFormat.Alert_INFO("Thông Báo", "Cập nhật quyền thành công !");
                GetUserPermisstion();
            }
            catch (Exception ex)
            {

                HTML.clsFormat.Alert_ERROR("Lỗi", ex.Message);
            }
        }
        #endregion

        #region[Clear-Text]
        private void ClearText()
        {
            hdIDGroup_User.Text = string.Empty;
            hdIDModulesMain.Text = string.Empty;
            hdIDModulesParrent.Text = string.Empty;
            txtModulesMain.Text = string.Empty;
            txtModulesParrent.Text = string.Empty;
            txtGroupName.Text = string.Empty;
            txtDescription.Text = string.Empty;
            chkAddNew.Checked = false;
            chkEdit.Checked = false;
            chkView.Checked = false;
            chkDel.Checked = false;
            chkReview.Checked = false;
            chkCancel.Checked = false;
            chkPrint.Checked = false;
            chkIsPageModuleMain.Checked = false;
            chkIsPageModulesParrent.Checked = false;
        }
        #endregion

        #region[Permisstion]
        private void CheckPermisstion()
        {
            if (Session["login"] != null && Session["USer_Detail_Id"].ToString() != string.Empty)
            {
                bool Is_BtnAdd;
                bool Is_BtnEdit;
                bool Is_BtnView;
                bool Is_BtnDel;
                bool Is_BtnPrint;
                bool Is_BtnCancel;
                bool Is_BtnReview;

                SecurityServices.HasPermisstion_Btn(StringContent.Unit, out Is_BtnAdd, out Is_BtnEdit, out Is_BtnDel, out Is_BtnView, out Is_BtnCancel, out Is_BtnPrint, out Is_BtnReview);
                if (Is_BtnAdd == false)
                {
                    btnAddNew.Visible = false;
                }
                if (Is_BtnEdit == false)
                {
                    btnEdit.Visible = false;
                }
                if (Is_BtnView == false)
                {
                    PanelMainUserPermisstion.Visible = false;
                }
                if (Is_BtnDel == false)
                {
                    btnDel.Visible = false;
                }
                if (Is_BtnPrint == false)
                {
                    btnExport.Visible = false;
                }
            }
        }
        private bool CheckPermisstionDobclick()
        {
            var check = false;
            if (Session["login"] != null && Session["USer_Detail_Id"].ToString() != string.Empty)
            {
                bool Is_BtnAdd;
                bool Is_BtnEdit;
                bool Is_BtnView;
                bool Is_BtnDel;
                bool Is_BtnPrint;
                bool Is_BtnCancel;
                bool Is_BtnReview;

                SecurityServices.HasPermisstion_Btn(StringContent.Unit, out Is_BtnAdd, out Is_BtnEdit, out Is_BtnDel, out Is_BtnView, out Is_BtnCancel, out Is_BtnPrint, out Is_BtnReview);
                if (Is_BtnEdit == false)
                {
                    check = true;
                }
            }
            return check;
        }
        #endregion
    }
}